<template>
  <div class="recom">
    <div v-for="item in recom_list" :key="item.id">
      <div class="recom_item">
        <a @click="voplay(item.video.id)">
          <div class="videoplayer">
            <video :src="item.video.url" :poster="item.video.imgUrl"></video>
            <div class="title">{{ item.title }}</div>
            <div class="play-btn"></div>
            <div class="info-bar">
              <div class="time">{{ item.video.dur | getTime }}</div>
            </div>
          </div>
        </a>
      </div>
      <div class="video-info">
        <div class="video-info-left">
          <img :src="item.user.avatarurl" alt="" />
          <div class="user-nickname">{{ item.user.nickName }}</div>
        </div>
        <div class="video-info-right">
          <div>
            <span class="iconfont icon-dianzan"></span
            ><span>{{ item.upCount }}</span>
          </div>
          <div>
            <span class="iconfont icon-ic_liaotian"></span
            ><span>{{ item.shareCount }}</span>
          </div>
          <div><span class="iconfont icon-fenxiang"></span><span></span></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "Recom",
  data() {
    return {
      recom_list: [],
      video_id: "",
      end_url: "",
    };
  },
  methods: {
    voplay(id) {
      this.$router.push({
        name: "videoplay",
        params: { id: id, url: this.end_url },
      });
    },
  },
  filters: {
    getTime(value) {
      var getmin = Math.floor(value / 60);
      console.log(getmin >= 10);
      var getsec = value % 60;
      getmin = getmin >= 10 ? getmin : "0" + getmin;
      getsec = getsec >= 10 ? getsec : "0" + getsec;
      return getmin + ":" + getsec;
    },
  },
  mounted() {
    axios
      .get(
        "./json/recom.json"
      )
      .then((res) => {
        this.recom_list = res.data.data.feeds;
        console.log(this.recom_list);
        this.end_url =
          "recom.json";
      });
  },
};
</script>

<style scoped lang="less">
.recom {
  padding-bottom: 50px;
  .recom_item {
    width: 100%;
    height: 231px;
    position: relative;
    video {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 230px;
    }
    .title {
      position: absolute;
      top: 0;
      left: 0;
      color: #fff;
      font-family: PingFangSC-Medium, serif;
      font-size: 16px;
      line-height: 25px;
      z-index: 1;
      margin: 10px 15px 10px;
      overflow: hidden;
    }
    .play-btn {
      z-index: 10;
      position: absolute;
      left: 50%;
      top: 50%;
      margin-left: -25px;
      margin-top: -25px;
      width: 50px;
      height: 50px;
      background-image: url("../../../assets/video-btn-play.png");
      background-size: contain;
    }
    .time {
      position: absolute;
      right: 15px;
      bottom: 10px;
      font-size: 12px;
      line-height: 30px;
      color: #fff;
      background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.5));
    }
  }
  .video-info {
    display: flex;
    position: relative;
    justify-content: space-between;
    height: 46px;
    .video-info-left {
      display: flex;
      padding-left: 16px;
      align-items: center;

      img {
        display: inline-block;
        width: 22px;
        height: 22px;
        border-radius: 50%;
      }
      .user-nickname {
        font-size: 14px;
        color: #666;
        margin-left: 8px;
      }
    }
    .video-info-right {
      display: flex;
      align-items: center;
      > div {
        margin-right: 15px;
        .iconfont {
          font-size: 22px;
          color: #a5a5a5;
        }
        span {
          display: inline-block;
          font-size: 16px;
          padding-left: 7px;
        }
      }
    }
  }
}
</style>